﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
using DataAccess.Classes;

namespace Webmau.Controls
{
    public partial class BinhLuan : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                PopulateControls();
            }
        }

        private void PopulateControls()
        {
            string page = Request.QueryString["Page"] ?? "1";
            string idPhongTro = Request.QueryString["IDPhongTro"];
            int howManyPages = 0;
            string firstPageUrl = "";
            string pagerFormat = "";
            if (idPhongTro != "")
            {
                repComment.DataSource = DataAccess.Classes.BinhLuan.LayDanhSachBinhLuan(idPhongTro, page, out howManyPages);
                repComment.DataBind();
                firstPageUrl = Link.ToComment(idPhongTro);
                pagerFormat = Link.ToComment(idPhongTro, "{0}");
            }
            Pager1.Show(int.Parse(page), howManyPages, firstPageUrl, pagerFormat, true);
        }
    }
}